/*************************************************************************

Framework\System.Console.cpp

	-by Miles Chen (stainboyx@hotmail.com) 2008-12-27

*************************************************************************/

#pragma once

#include "commdef-int.h"

N System{N Console{

	void WriteLine(LPCWSTR lpszText)
	{
		WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), lpszText, String::Length(lpszText), NULL, NULL);
		WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), L"\n", 1, NULL, NULL);
	}
	void WriteLine(LPCSTR lpszText)
	{
		WriteConsoleA(GetStdHandle(STD_OUTPUT_HANDLE), lpszText, String::Length(lpszText), NULL, NULL);
		WriteConsoleA(GetStdHandle(STD_OUTPUT_HANDLE), "\n", 1, NULL, NULL);
	}

	int ExecuteCommand(LPCSTR lpszCommand)
	{
		typedef int(__cdecl* system)(const char* cmd);
		FARPROC p = GetProcAddress(LoadLibraryW(L"msvcrt"), "system");
		return ((system)p)(lpszCommand);
	}

}}